.class public Lcom/htc/android/footprints/utils/voice/Recorder;
.super Ljava/lang/Object;
.source "Recorder.java"

# interfaces
.implements Landroid/media/MediaPlayer$OnCompletionListener;
.implements Landroid/media/MediaPlayer$OnErrorListener;


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/htc/android/footprints/utils/voice/Recorder$OnStateChangedListener;
    }
.end annotation


# static fields
.field public static final IDLE_STATE:I = 0x0

.field public static final INTERNAL_ERROR:I = 0x2

.field public static final NO_ERROR:I = 0x0

.field public static final PAUSE_STATE:I = 0x3

.field public static final PLAYING_STATE:I = 0x2

.field public static final RECORDING_STATE:I = 0x1

.field static final SAMPLE_EXTENSION:Ljava/lang/String; = ".amr"

.field static final SAMPLE_LENGTH_KEY:Ljava/lang/String; = "sample_length"

.field static final SAMPLE_PATH_KEY:Ljava/lang/String; = "sample_path"

.field static final SAMPLE_PREFIX:Ljava/lang/String; = "footprints"

.field public static final SDCARD_ACCESS_ERROR:I = 0x1

.field static final TAG:Ljava/lang/String; = "Recorder"


# instance fields
.field mOnStateChangedListener:Lcom/htc/android/footprints/utils/voice/Recorder$OnStateChangedListener;

.field mPlayer:Landroid/media/MediaPlayer;

.field mRecorder:Landroid/media/MediaRecorder;

.field mSampleFile:Ljava/io/File;

.field public mSampleLength:I

.field mSampleStart:J

.field mState:I


# direct methods
.method public constructor <init>()V
    .locals 4

    .prologue
    const/4 v3, 0x0

    const/4 v2, 0x0

    .line 48
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 29
    iput v3, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mState:I

    .line 39
    iput-object v2, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mOnStateChangedListener:Lcom/htc/android/footprints/utils/voice/Recorder$OnStateChangedListener;

    .line 41
    const-wide/16 v0, 0x0

    iput-wide v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleStart:J

    .line 42
    iput v3, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleLength:I

    .line 43
    iput-object v2, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleFile:Ljava/io/File;

    .line 45
    iput-object v2, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mRecorder:Landroid/media/MediaRecorder;

    .line 46
    iput-object v2, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mPlayer:Landroid/media/MediaPlayer;

    .line 49
    return-void
.end method

.method public constructor <init>(Ljava/io/File;)V
    .locals 4
    .parameter "samplefile"

    .prologue
    const/4 v3, 0x0

    const/4 v2, 0x0

    .line 52
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 29
    iput v3, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mState:I

    .line 39
    iput-object v2, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mOnStateChangedListener:Lcom/htc/android/footprints/utils/voice/Recorder$OnStateChangedListener;

    .line 41
    const-wide/16 v0, 0x0

    iput-wide v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleStart:J

    .line 42
    iput v3, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleLength:I

    .line 43
    iput-object v2, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleFile:Ljava/io/File;

    .line 45
    iput-object v2, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mRecorder:Landroid/media/MediaRecorder;

    .line 46
    iput-object v2, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mPlayer:Landroid/media/MediaPlayer;

    .line 53
    iput-object p1, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleFile:Ljava/io/File;

    .line 54
    return-void
.end method

.method public constructor <init>(Ljava/lang/String;)V
    .locals 7
    .parameter "filepath"

    .prologue
    const/4 v6, 0x0

    const/4 v5, 0x0

    .line 56
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 29
    iput v6, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mState:I

    .line 39
    iput-object v5, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mOnStateChangedListener:Lcom/htc/android/footprints/utils/voice/Recorder$OnStateChangedListener;

    .line 41
    const-wide/16 v3, 0x0

    iput-wide v3, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleStart:J

    .line 42
    iput v6, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleLength:I

    .line 43
    iput-object v5, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleFile:Ljava/io/File;

    .line 45
    iput-object v5, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mRecorder:Landroid/media/MediaRecorder;

    .line 46
    iput-object v5, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mPlayer:Landroid/media/MediaPlayer;

    .line 57
    if-nez p1, :cond_1

    .line 83
    :cond_0
    :goto_0
    return-void

    .line 58
    :cond_1
    const-string v3, ""

    invoke-virtual {p1, v3}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z

    move-result v3

    if-nez v3, :cond_0

    .line 60
    new-instance v1, Ljava/io/File;

    invoke-direct {v1, p1}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 61
    .local v1, file:Ljava/io/File;
    invoke-virtual {v1}, Ljava/io/File;->exists()Z

    move-result v3

    if-eqz v3, :cond_0

    .line 63
    iput-object v1, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleFile:Ljava/io/File;

    .line 66
    :try_start_0
    new-instance v2, Landroid/media/MediaPlayer;

    invoke-direct {v2}, Landroid/media/MediaPlayer;-><init>()V

    .line 67
    .local v2, mp:Landroid/media/MediaPlayer;
    invoke-virtual {v2}, Landroid/media/MediaPlayer;->reset()V

    .line 68
    iget-object v3, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleFile:Ljava/io/File;

    invoke-virtual {v3}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3}, Landroid/media/MediaPlayer;->setDataSource(Ljava/lang/String;)V

    .line 69
    invoke-virtual {v2}, Landroid/media/MediaPlayer;->prepare()V

    .line 70
    invoke-virtual {v2}, Landroid/media/MediaPlayer;->getDuration()I

    move-result v3

    iput v3, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleLength:I

    .line 71
    invoke-virtual {v2}, Landroid/media/MediaPlayer;->release()V
    :try_end_0
    .catch Ljava/lang/IllegalArgumentException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Ljava/lang/IllegalStateException; {:try_start_0 .. :try_end_0} :catch_1
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_2

    goto :goto_0

    .line 73
    .end local v2           #mp:Landroid/media/MediaPlayer;
    :catch_0
    move-exception v3

    move-object v0, v3

    .line 75
    .local v0, e:Ljava/lang/IllegalArgumentException;
    invoke-virtual {v0}, Ljava/lang/IllegalArgumentException;->printStackTrace()V

    goto :goto_0

    .line 76
    .end local v0           #e:Ljava/lang/IllegalArgumentException;
    :catch_1
    move-exception v3

    move-object v0, v3

    .line 78
    .local v0, e:Ljava/lang/IllegalStateException;
    invoke-virtual {v0}, Ljava/lang/IllegalStateException;->printStackTrace()V

    goto :goto_0

    .line 79
    .end local v0           #e:Ljava/lang/IllegalStateException;
    :catch_2
    move-exception v3

    move-object v0, v3

    .line 81
    .local v0, e:Ljava/io/IOException;
    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_0
.end method

.method private setError(I)V
    .locals 1
    .parameter "error"

    .prologue
    .line 292
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mOnStateChangedListener:Lcom/htc/android/footprints/utils/voice/Recorder$OnStateChangedListener;

    if-eqz v0, :cond_0

    .line 293
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mOnStateChangedListener:Lcom/htc/android/footprints/utils/voice/Recorder$OnStateChangedListener;

    invoke-interface {v0, p1}, Lcom/htc/android/footprints/utils/voice/Recorder$OnStateChangedListener;->onError(I)V

    .line 294
    :cond_0
    return-void
.end method

.method private setState(I)V
    .locals 1
    .parameter "state"

    .prologue
    .line 279
    iget v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mState:I

    if-ne p1, v0, :cond_0

    .line 284
    :goto_0
    return-void

    .line 282
    :cond_0
    iput p1, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mState:I

    .line 283
    iget v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mState:I

    invoke-direct {p0, v0}, Lcom/htc/android/footprints/utils/voice/Recorder;->signalStateChanged(I)V

    goto :goto_0
.end method

.method private signalStateChanged(I)V
    .locals 1
    .parameter "state"

    .prologue
    .line 287
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mOnStateChangedListener:Lcom/htc/android/footprints/utils/voice/Recorder$OnStateChangedListener;

    if-eqz v0, :cond_0

    .line 288
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mOnStateChangedListener:Lcom/htc/android/footprints/utils/voice/Recorder$OnStateChangedListener;

    invoke-interface {v0, p1}, Lcom/htc/android/footprints/utils/voice/Recorder$OnStateChangedListener;->onStateChanged(I)V

    .line 289
    :cond_0
    return-void
.end method


# virtual methods
.method public clear()V
    .locals 1

    .prologue
    const/4 v0, 0x0

    .line 161
    invoke-virtual {p0}, Lcom/htc/android/footprints/utils/voice/Recorder;->stop()V

    .line 163
    iput v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleLength:I

    .line 165
    invoke-direct {p0, v0}, Lcom/htc/android/footprints/utils/voice/Recorder;->signalStateChanged(I)V

    .line 166
    return-void
.end method

.method public delete()V
    .locals 2

    .prologue
    const/4 v1, 0x0

    .line 145
    invoke-virtual {p0}, Lcom/htc/android/footprints/utils/voice/Recorder;->stop()V

    .line 147
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleFile:Ljava/io/File;

    if-eqz v0, :cond_0

    .line 148
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleFile:Ljava/io/File;

    invoke-virtual {v0}, Ljava/io/File;->delete()Z

    .line 150
    :cond_0
    const/4 v0, 0x0

    iput-object v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleFile:Ljava/io/File;

    .line 151
    iput v1, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleLength:I

    .line 153
    invoke-direct {p0, v1}, Lcom/htc/android/footprints/utils/voice/Recorder;->signalStateChanged(I)V

    .line 154
    return-void
.end method

.method public getDuration()J
    .locals 2

    .prologue
    .line 273
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mPlayer:Landroid/media/MediaPlayer;

    if-nez v0, :cond_0

    const-wide/16 v0, -0x1

    .line 275
    :goto_0
    return-wide v0

    :cond_0
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->getDuration()I

    move-result v0

    int-to-long v0, v0

    goto :goto_0
.end method

.method public getMaxAmplitude()I
    .locals 2

    .prologue
    .line 92
    iget v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mState:I

    const/4 v1, 0x1

    if-eq v0, v1, :cond_0

    .line 93
    const/4 v0, 0x0

    .line 94
    :goto_0
    return v0

    :cond_0
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mRecorder:Landroid/media/MediaRecorder;

    invoke-virtual {v0}, Landroid/media/MediaRecorder;->getMaxAmplitude()I

    move-result v0

    goto :goto_0
.end method

.method public onCompletion(Landroid/media/MediaPlayer;)V
    .locals 1
    .parameter "mp"

    .prologue
    .line 267
    const/4 v0, 0x0

    invoke-direct {p0, v0}, Lcom/htc/android/footprints/utils/voice/Recorder;->setState(I)V

    .line 268
    invoke-virtual {p0}, Lcom/htc/android/footprints/utils/voice/Recorder;->stop()V

    .line 270
    return-void
.end method

.method public onError(Landroid/media/MediaPlayer;II)Z
    .locals 1
    .parameter "mp"
    .parameter "what"
    .parameter "extra"

    .prologue
    const/4 v0, 0x1

    .line 261
    invoke-virtual {p0}, Lcom/htc/android/footprints/utils/voice/Recorder;->stop()V

    .line 262
    invoke-direct {p0, v0}, Lcom/htc/android/footprints/utils/voice/Recorder;->setError(I)V

    .line 263
    return v0
.end method

.method public progress()I
    .locals 4

    .prologue
    .line 128
    iget v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mState:I

    const/4 v1, 0x1

    if-eq v0, v1, :cond_0

    iget v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mState:I

    const/4 v1, 0x2

    if-ne v0, v1, :cond_1

    .line 129
    :cond_0
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v0

    iget-wide v2, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleStart:J

    sub-long/2addr v0, v2

    long-to-int v0, v0

    .line 130
    :goto_0
    return v0

    :cond_1
    const/4 v0, 0x0

    goto :goto_0
.end method

.method public restoreState(Landroid/os/Bundle;)V
    .locals 5
    .parameter "recorderState"

    .prologue
    const/4 v4, -0x1

    .line 98
    const-string v3, "sample_path"

    invoke-virtual {p1, v3}, Landroid/os/Bundle;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    .line 99
    .local v2, samplePath:Ljava/lang/String;
    if-nez v2, :cond_1

    .line 117
    :cond_0
    :goto_0
    return-void

    .line 101
    :cond_1
    const-string v3, "sample_length"

    invoke-virtual {p1, v3, v4}, Landroid/os/Bundle;->getInt(Ljava/lang/String;I)I

    move-result v1

    .line 102
    .local v1, sampleLength:I
    if-eq v1, v4, :cond_0

    .line 105
    new-instance v0, Ljava/io/File;

    invoke-direct {v0, v2}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 106
    .local v0, file:Ljava/io/File;
    invoke-virtual {v0}, Ljava/io/File;->exists()Z

    move-result v3

    if-eqz v3, :cond_0

    .line 108
    iget-object v3, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleFile:Ljava/io/File;

    if-eqz v3, :cond_2

    iget-object v3, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleFile:Ljava/io/File;

    invoke-virtual {v3}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v0}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v3, v4}, Ljava/lang/String;->compareTo(Ljava/lang/String;)I

    move-result v3

    if-eqz v3, :cond_0

    .line 112
    :cond_2
    invoke-virtual {p0}, Lcom/htc/android/footprints/utils/voice/Recorder;->delete()V

    .line 113
    iput-object v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleFile:Ljava/io/File;

    .line 114
    iput v1, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleLength:I

    .line 116
    const/4 v3, 0x0

    invoke-direct {p0, v3}, Lcom/htc/android/footprints/utils/voice/Recorder;->signalStateChanged(I)V

    goto :goto_0
.end method

.method public sampleFile()Ljava/io/File;
    .locals 1

    .prologue
    .line 138
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleFile:Ljava/io/File;

    return-object v0
.end method

.method public sampleLength()I
    .locals 1

    .prologue
    .line 134
    iget v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleLength:I

    return v0
.end method

.method public saveState(Landroid/os/Bundle;)V
    .locals 2
    .parameter "recorderState"

    .prologue
    .line 87
    const-string v0, "sample_path"

    iget-object v1, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleFile:Ljava/io/File;

    invoke-virtual {v1}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {p1, v0, v1}, Landroid/os/Bundle;->putString(Ljava/lang/String;Ljava/lang/String;)V

    .line 88
    const-string v0, "sample_length"

    iget v1, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleLength:I

    invoke-virtual {p1, v0, v1}, Landroid/os/Bundle;->putInt(Ljava/lang/String;I)V

    .line 89
    return-void
.end method

.method public setOnStateChangedListener(Lcom/htc/android/footprints/utils/voice/Recorder$OnStateChangedListener;)V
    .locals 0
    .parameter "listener"

    .prologue
    .line 120
    iput-object p1, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mOnStateChangedListener:Lcom/htc/android/footprints/utils/voice/Recorder$OnStateChangedListener;

    .line 121
    return-void
.end method

.method public startPlayback()V
    .locals 5

    .prologue
    const/4 v4, 0x0

    const/4 v3, 0x2

    .line 221
    invoke-virtual {p0}, Lcom/htc/android/footprints/utils/voice/Recorder;->stop()V

    .line 223
    new-instance v1, Landroid/media/MediaPlayer;

    invoke-direct {v1}, Landroid/media/MediaPlayer;-><init>()V

    iput-object v1, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mPlayer:Landroid/media/MediaPlayer;

    .line 225
    :try_start_0
    iget-object v1, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mPlayer:Landroid/media/MediaPlayer;

    iget-object v2, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleFile:Ljava/io/File;

    invoke-virtual {v2}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v1, v2}, Landroid/media/MediaPlayer;->setDataSource(Ljava/lang/String;)V

    .line 226
    iget-object v1, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v1, p0}, Landroid/media/MediaPlayer;->setOnCompletionListener(Landroid/media/MediaPlayer$OnCompletionListener;)V

    .line 227
    iget-object v1, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v1, p0}, Landroid/media/MediaPlayer;->setOnErrorListener(Landroid/media/MediaPlayer$OnErrorListener;)V

    .line 228
    iget-object v1, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v1}, Landroid/media/MediaPlayer;->prepare()V

    .line 229
    iget-object v1, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v1}, Landroid/media/MediaPlayer;->getDuration()I

    move-result v1

    iput v1, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleLength:I

    .line 230
    iget-object v1, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v1}, Landroid/media/MediaPlayer;->start()V
    :try_end_0
    .catch Ljava/lang/IllegalArgumentException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_1

    .line 241
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v1

    iput-wide v1, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleStart:J

    .line 242
    invoke-direct {p0, v3}, Lcom/htc/android/footprints/utils/voice/Recorder;->setState(I)V

    .line 243
    :goto_0
    return-void

    .line 231
    :catch_0
    move-exception v1

    move-object v0, v1

    .line 232
    .local v0, e:Ljava/lang/IllegalArgumentException;
    invoke-direct {p0, v3}, Lcom/htc/android/footprints/utils/voice/Recorder;->setError(I)V

    .line 233
    iput-object v4, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mPlayer:Landroid/media/MediaPlayer;

    goto :goto_0

    .line 235
    .end local v0           #e:Ljava/lang/IllegalArgumentException;
    :catch_1
    move-exception v1

    move-object v0, v1

    .line 236
    .local v0, e:Ljava/io/IOException;
    const/4 v1, 0x1

    invoke-direct {p0, v1}, Lcom/htc/android/footprints/utils/voice/Recorder;->setError(I)V

    .line 237
    iput-object v4, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mPlayer:Landroid/media/MediaPlayer;

    goto :goto_0
.end method

.method public startRecording()V
    .locals 5

    .prologue
    const/4 v4, 0x1

    .line 169
    invoke-virtual {p0}, Lcom/htc/android/footprints/utils/voice/Recorder;->stop()V

    .line 171
    iget-object v2, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleFile:Ljava/io/File;

    if-nez v2, :cond_2

    .line 173
    new-instance v1, Ljava/io/File;

    invoke-static {}, Lcom/htc/android/footprints/utils/voice/FootprintVoiceManager;->getDirectory()Ljava/lang/String;

    move-result-object v2

    invoke-direct {v1, v2}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 174
    .local v1, sampleDir:Ljava/io/File;
    invoke-virtual {v1}, Ljava/io/File;->exists()Z

    move-result v2

    if-nez v2, :cond_0

    .line 175
    invoke-virtual {v1}, Ljava/io/File;->mkdirs()Z

    .line 177
    :cond_0
    invoke-virtual {v1}, Ljava/io/File;->canWrite()Z

    move-result v2

    if-nez v2, :cond_1

    .line 178
    new-instance v1, Ljava/io/File;

    .end local v1           #sampleDir:Ljava/io/File;
    invoke-static {}, Landroid/os/Environment;->getExternalStorageDirectory()Ljava/io/File;

    move-result-object v2

    invoke-virtual {v2}, Ljava/io/File;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-direct {v1, v2}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 181
    .restart local v1       #sampleDir:Ljava/io/File;
    :cond_1
    :try_start_0
    const-string v2, "footprints"

    const-string v3, ".amr"

    invoke-static {v2, v3, v1}, Ljava/io/File;->createTempFile(Ljava/lang/String;Ljava/lang/String;Ljava/io/File;)Ljava/io/File;

    move-result-object v2

    iput-object v2, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleFile:Ljava/io/File;
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    .line 189
    .end local v1           #sampleDir:Ljava/io/File;
    :cond_2
    new-instance v2, Landroid/media/MediaRecorder;

    invoke-direct {v2}, Landroid/media/MediaRecorder;-><init>()V

    iput-object v2, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mRecorder:Landroid/media/MediaRecorder;

    .line 190
    iget-object v2, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mRecorder:Landroid/media/MediaRecorder;

    invoke-virtual {v2, v4}, Landroid/media/MediaRecorder;->setAudioSource(I)V

    .line 191
    iget-object v2, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mRecorder:Landroid/media/MediaRecorder;

    const/4 v3, 0x2

    invoke-virtual {v2, v3}, Landroid/media/MediaRecorder;->setOutputFormat(I)V

    .line 192
    iget-object v2, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mRecorder:Landroid/media/MediaRecorder;

    invoke-virtual {v2, v4}, Landroid/media/MediaRecorder;->setAudioEncoder(I)V

    .line 193
    iget-object v2, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mRecorder:Landroid/media/MediaRecorder;

    iget-object v3, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleFile:Ljava/io/File;

    invoke-virtual {v3}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3}, Landroid/media/MediaRecorder;->setOutputFile(Ljava/lang/String;)V

    .line 195
    :try_start_1
    iget-object v2, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mRecorder:Landroid/media/MediaRecorder;

    invoke-virtual {v2}, Landroid/media/MediaRecorder;->prepare()V
    :try_end_1
    .catch Ljava/lang/IllegalStateException; {:try_start_1 .. :try_end_1} :catch_1
    .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_2

    .line 203
    :goto_0
    iget-object v2, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mRecorder:Landroid/media/MediaRecorder;

    invoke-virtual {v2}, Landroid/media/MediaRecorder;->start()V

    .line 204
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v2

    iput-wide v2, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleStart:J

    .line 205
    invoke-direct {p0, v4}, Lcom/htc/android/footprints/utils/voice/Recorder;->setState(I)V

    .line 206
    :goto_1
    return-void

    .line 183
    .restart local v1       #sampleDir:Ljava/io/File;
    :catch_0
    move-exception v2

    move-object v0, v2

    .line 184
    .local v0, e:Ljava/io/IOException;
    invoke-direct {p0, v4}, Lcom/htc/android/footprints/utils/voice/Recorder;->setError(I)V

    goto :goto_1

    .line 196
    .end local v0           #e:Ljava/io/IOException;
    .end local v1           #sampleDir:Ljava/io/File;
    :catch_1
    move-exception v2

    move-object v0, v2

    .line 198
    .local v0, e:Ljava/lang/IllegalStateException;
    invoke-virtual {v0}, Ljava/lang/IllegalStateException;->printStackTrace()V

    goto :goto_0

    .line 199
    .end local v0           #e:Ljava/lang/IllegalStateException;
    :catch_2
    move-exception v2

    move-object v0, v2

    .line 201
    .local v0, e:Ljava/io/IOException;
    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_0
.end method

.method public state()I
    .locals 1

    .prologue
    .line 124
    iget v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mState:I

    return v0
.end method

.method public stop()V
    .locals 0

    .prologue
    .line 256
    invoke-virtual {p0}, Lcom/htc/android/footprints/utils/voice/Recorder;->stopRecording()V

    .line 257
    invoke-virtual {p0}, Lcom/htc/android/footprints/utils/voice/Recorder;->stopPlayback()V

    .line 258
    return-void
.end method

.method public stopPlayback()V
    .locals 1

    .prologue
    .line 246
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mPlayer:Landroid/media/MediaPlayer;

    if-nez v0, :cond_0

    .line 253
    :goto_0
    return-void

    .line 249
    :cond_0
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->stop()V

    .line 250
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->release()V

    .line 251
    const/4 v0, 0x0

    iput-object v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mPlayer:Landroid/media/MediaPlayer;

    .line 252
    const/4 v0, 0x0

    invoke-direct {p0, v0}, Lcom/htc/android/footprints/utils/voice/Recorder;->setState(I)V

    goto :goto_0
.end method

.method public stopRecording()V
    .locals 4

    .prologue
    .line 209
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mRecorder:Landroid/media/MediaRecorder;

    if-nez v0, :cond_0

    .line 218
    :goto_0
    return-void

    .line 212
    :cond_0
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mRecorder:Landroid/media/MediaRecorder;

    invoke-virtual {v0}, Landroid/media/MediaRecorder;->stop()V

    .line 213
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mRecorder:Landroid/media/MediaRecorder;

    invoke-virtual {v0}, Landroid/media/MediaRecorder;->release()V

    .line 214
    const/4 v0, 0x0

    iput-object v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mRecorder:Landroid/media/MediaRecorder;

    .line 216
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v0

    iget-wide v2, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleStart:J

    sub-long/2addr v0, v2

    long-to-int v0, v0

    iput v0, p0, Lcom/htc/android/footprints/utils/voice/Recorder;->mSampleLength:I

    .line 217
    const/4 v0, 0x0

    invoke-direct {p0, v0}, Lcom/htc/android/footprints/utils/voice/Recorder;->setState(I)V

    goto :goto_0
.end method
